const path = require("path");
const express = require("express");
const app = express();

const http = require("http");
// 创建服务
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);

io.on("connection", (socket) => {
  // 1. 当客户端连接上了，欢迎一下
  io.emit("all", {
    content: "欢迎xxx进来了",
  });
});

server.listen(3000, () => {
  console.log("服务器启动成功，访问地址：http://localhost:3000");
});
